package handler

import (
	"github.com/gin-gonic/gin"
	"user-auth-sys/model"
)

func CreateNews(c *gin.Context) {
	title := c.PostForm("title")
	content := c.PostForm("content")
	news := model.News{
		Title:   title,
		Content: content,
	}
	model.DB.Create(&news)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "发布成功",
	})
	return
}
func Detail(c *gin.Context) {
	var news []model.News
	model.DB.Find(&news)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "查看成功",
		"data": news,
	})
	return
}
